package com.other.springbootconfigureorder.test;

import com.gantang.order.open.dto.*;
import com.gantang.order.open.service.OrderValidatorService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@RestController
@RequestMapping("customConfiguration")
public class CustomConfigurationController {
    @Autowired
    OrderValidatorService orderFeatureTableService;

    @PostMapping("monitor")
    public Map<String, String> monitor() {
        return orderFeatureTableService.monitorPool();
    }

    @PostMapping("select")
    public VerificationResultDto select(@RequestBody VerificationReqDto verificationParamsDto) {
        return orderFeatureTableService.checkSelected(verificationParamsDto);
    }

    @PostMapping("removeConfigOrder")
    public ResultDto removeConfigOrder(String featureTableKey) {
        return orderFeatureTableService.removeConfigOrder(featureTableKey);
    }

    @PostMapping("upsertConfigOrder")
    public ResultDto upsertConfigOrder(@RequestBody WrapFeatureTableDto customFeatureTableDto) {
        return orderFeatureTableService.upsertConfigTable(customFeatureTableDto);
    }

    @PostMapping("confirmSelect")
    public ConfirmSelectResultDto confirmSelect(@RequestBody VerificationReqDto verificationParamsDto) {
        return orderFeatureTableService.getSelectFeatures(verificationParamsDto);
    }
}